import { defineStore } from 'pinia'
import { getCategoryListAPI, getGoodListByCidAPI, getGoodListByContentAPI } from '@/apis/goods'
import { ref } from 'vue'
export const useGoodsStore = defineStore('goods', () => {
    const goodList = ref([]);
    const categoryList = ref([]);
    const getCategoryList = async () => {
        const res = await getCategoryListAPI();
        categoryList.value = res.data;
        return res.data;
    }
    const getGoodListByCid = async (cid) => {
        const res = await getGoodListByCidAPI(cid);
        goodList.value = res.data;
        return res.data;
    }
    const getGoodListByContent = async (content) => {
        const res = await getGoodListByContentAPI(content)
        goodList.value = res.data;
        return res.data;
    }
    return { getCategoryList, goodsList, categoryList, getGoodListByCid, getGoodListByContent }
}, {
    persist: true
})
